/*******************************************************************************
* @Filename      : bsp_wdg.c

* @Description   : bsp_wdg.c

* @Version       : 1.0.0

* @Date          : 2023.09.25
*******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "bsp_wdg.h"

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/
#define IWDG_Prescaler IWDG_Prescaler_256
#define IWDG_Reload    0xFF

/* Global variables ----------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

/* Private function prototypes -----------------------------------------------*/

/* Exported functions --------------------------------------------------------*/
/*******************************************************************************
* @Name      : BSP_WDG_Init
* @Purpose   : BSP_WDG_Init
* @Param     : None
* @Retval    : None
*******************************************************************************/
void BSP_WDG_Init(void)
{
    RCC_APB1PeriphClockCmd(RCC_APB1ENR_IWDG, ENABLE);

    BSP_WDG_Wakeup();

    PVU_CheckStatus();
    IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
    IWDG_SetPrescaler(IWDG_Prescaler);
    PVU_CheckStatus();

    RVU_CheckStatus();
    IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
    IWDG_SetReload(IWDG_Reload);
    RVU_CheckStatus();

    BSP_WDG_Reload();

    BSP_WDG_Enable();
}

/* Overrride functions -------------------------------------------------------*/

/* Private functions ---------------------------------------------------------*/

/* End of File ---------------------------------------------------------------*/
